package minimips.util;

public class NumberUtilities {

	/**Return a 64 bit number by appending two 32 bit numbers (word2 is appended after word1)
	 * 
	 * @param word1 The word to be shifted to the left by 32 bits.
	 * @param word2 The word to be or'd after word1 is shifted to the left.
	 * @return
	 */
	public static long appendWords(long word1, long word2) {
		return orNumbersAfterShift(word1, word2, BitUnits.HALF_WORD);
	}
	
	/**Append (i.e., OR) int2 to int1 after left-shifting int1 by a specified number of bits
	 * 
	 * @param int1 The integer to be shifted by bitShift bits to the left.
	 * @param int2 The integer to be or'd after int1 is shifted to the left.
	 * @param bitShift The number of bits that int1 will shift.
	 * @return
	 */
	public static long orNumbersAfterShift(long int1, long int2, BitUnits bitShift) {
		return int2 | (int1 << bitShift.getNumberOfBits());
	}
	
	/**Append (i.e., OR) int2 to int1 after left-shifting int1 by a specified number of bits
	 * 
	 * @param int1 The integer to be shifted by bitShift bits to the left.
	 * @param int2 The integer to be or'd after int1 is shifted to the left.
	 * @param bitShift The number of bits that int1 will shift.
	 * @return
	 */
	public static long orNumbersAfterShift(long int1, long int2, int bitShift) {
		return int2 | (int1 << bitShift);
	}
//	
//	public static void main(String[] args) {
//		long sample = 0x0;
//		sample = sample | 0x12F;
//		sample = sample << 48;
//		sample = sample | 0x1;
//		sample = sample & 0xff;
//		System.out.println(Long.toString(sample, 16));
//		System.out.println(Long.toBinaryString(sample));
//	}
	
}
